package com.insigma.business.qrcode.appmgt.controller;

import com.insigma.business.qrcode.appmgt.dto.CommonCodeappRemovedDTO;
import com.insigma.business.qrcode.appmgt.dto.request.CommonCodeappRemovedInsertRequest;
import com.insigma.business.qrcode.appmgt.dto.request.CommonCodeappRemovedUpdateRequest;
import com.insigma.business.qrcode.appmgt.dto.request.CommonCodeappRemovedSearchRequest;
import com.insigma.business.qrcode.appmgt.service.CommonCodeappRemovedService;
import com.insigma.business.qrcode.common.template.BasePagingResponse;
import com.insigma.business.qrcode.common.vo.BaseResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Api(value = "码应用上下架")
@RequestMapping("/web/commonCodeappRemoved")
@RestController("commonCodeappRemovedController")
public class CommonCodeappRemovedController {
    @Resource
    CommonCodeappRemovedService commonCodeappRemovedService;

    @ApiOperation("查询所有数据列表")
    @PostMapping("/searchCodeApp")
    public BasePagingResponse<List<CommonCodeappRemovedDTO>> searchAll(@RequestBody CommonCodeappRemovedSearchRequest request){
        return commonCodeappRemovedService.searchAll(request);
    }

    @ApiOperation("查询启用数据列表")
    @PostMapping("/searchCodeAppEnable")
    public BaseResponse<List<CommonCodeappRemovedDTO>> searchEnable(){
        return commonCodeappRemovedService.searchEnable();
    }

    @ApiOperation("数据新增")
    @PostMapping("/codeAppInsert")
    public BaseResponse<String> dataInsert(@RequestBody CommonCodeappRemovedInsertRequest request){
        return commonCodeappRemovedService.dataInsert(request);
    }

    @ApiOperation("数据查看")
    @PostMapping("/codeAppView")
    public BaseResponse<CommonCodeappRemovedDTO> dataView(@RequestParam("appId") String appId){
        return commonCodeappRemovedService.dataView(appId);
    }

    @ApiOperation("数据更新")
    @PostMapping("/codeAppUpdate")
    public BaseResponse<String> dataUpdate(@RequestBody CommonCodeappRemovedUpdateRequest request){
        return commonCodeappRemovedService.dataUpdate(request);
    }

    @ApiOperation("更新启用标记")
    @PostMapping("/codeAppEnableUpdate")
    public BaseResponse<String> enableUpdate(@RequestParam("appId") String appId,
                                             @RequestParam("appStatus") String appStatus){
        return commonCodeappRemovedService.enableUpdate(appId,appStatus);
    }

    @ApiOperation("数据删除")
    @PostMapping("/codeAppDelete")
    public BaseResponse<String> dataDelete(@RequestParam("appId") String appId){
        return commonCodeappRemovedService.dataDelete(appId);
    }
}
